package RecordManagement;

public class ScanType {
	
	/* Type of comparison operation */
	int compOp;
	final public static int OP_EQ = 1;
	final public static int OP_LT = 2;
	final public static int OP_GT = 3;
	final public static int OP_NE = 4;
	final public static int OP_LE = 5;
	final public static int OP_GE = 6;
	final public static int OP_NO = 7;
	
	/* Type of the attribute */
	int attrType;
	final public static int TYPE_INT = 8;
	final public static int TYPE_STRING = 9;
	
	/* Type of pin stragety 
	 * PIN_NORMAL means pin one page each time and unpin the former pinned page.
	 * PIN_EFFICIENT means pin pages as much as possible,
	 * which means pinning all free pages in buffer manager,
	 * and unpin former pinned pages as well.
	 * */
	int pinHint;
	final public static int PIN_NORMAL = 10;
	final public static int PIN_EFFICIENT = 11;
	
	/* The offset and length of the attribute to be compared in the bytes of a record,
	 * and the value of attribute to be compared to.
	 * */
	int attrLength;
	int attrOffset;
	byte[] compValue;
	
	public ScanType(int attrType, int attrLength, int attrOffset, int compOp, byte[] value, int pinHint){
		this.attrType = attrType;
		this.attrLength = attrLength;
		this.attrOffset = attrOffset;
		this.compOp = compOp;
		this.compValue = value;
		this.pinHint = pinHint;
		if (compOp != OP_NO) {
			compValue = value.clone();
			if (compValue.length != attrLength)
				throw new RM_Abort_Exception("Fatal");
		}
	}
}